package asynqmq

import (
	"encoding/json"
	"gitee.com/jianbiao/go-util/xerr"
	"github.com/hibiken/asynq"
	"github.com/pkg/errors"
)

const (
	TypeHomestayOrderCloseDelivery = "homestay:order:close"
)

type HomestayOrderCloseTaskPayload struct {
	Sn string
}

func NewHomestayOrderCloseTask(sn string) (*asynq.Task, error) {
	payload, err := json.Marshal(HomestayOrderCloseTaskPayload{sn})
	if err != nil{
		return nil, errors.Wrapf(xerr.NewErrMsg("创建订单延迟任务失败"), "创建订单延迟任务失败，err：%v", err)
	}
	return asynq.NewTask(TypeHomestayOrderCloseDelivery, payload), nil
}